﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Epsilon.Expr;
using Epsilon.Typing;

namespace Epsilon.Output
{
    public partial class Writer
    {
        public void WriteRecordDef(string name, List<Tuple<string,Expression>> fields)
        {
            int savedIdt = indent.Length;
            Output("-record(" + name + ", {");
            SetIndent(col);

            for (int i = 0; i < fields.Count; i++)
            {
                if (i != 0)
                    OutputNewline(",");
                Output(fields[i].Item1);
                Output(" = ");
                Write(fields[i].Item2);
            }

            Output("}).");
            SetIndent(savedIdt);
            OutputNewline();
        }

        public void WriteSpec(string name, TypeLabel label)
        {
            OutputNewline("% -spec(" + name + ", " + label.Type.ToString() + ", " +
                label.MaxPidLabel.ToString() + ", " + label.MinPidLabel.ToString() +
                ", " + label.SecLabel.ToString() + ").");
        }

        public void WriteAttribute(AttributeExpr e)
        {
            Output("-" + e.Name + "(");
            for (int i = 0; i < e.Expressions.Count; i++)
            {
                if (i > 0)
                    Output(", ");
                Write(e.Expressions[i]);
            }
            OutputNewline(").");
        }
    }
}
